import request from "@/utils/request";

import { GetUserInfoResponse } from "./model/loginModel";

const enum Api {
  userLogin = "/admin/acl/index/login",
  userLogout = "/admin/acl/index/logout",
  getUserInfo = "/admin/acl/index/info",
}

/**
 * 用户登录
 * @param username 用户名
 * @param password 密码
 * @returns { token: string }
 */
export const UserLoginApi = (username: string, password: string) => {
  return request.post<any, { token: string }>(Api.userLogin, {
    username,
    password,
  });
};

/**
 * 用户退出登录
 * @returns null
 */
export const UserLogoutApi = () => {
  return request.post<any, null>(Api.userLogout);
};

/**
 * 获取用户信息
 * @returns GetUserInfoResponse
 */
export const GetUserInfoApi = () => {
  return request.get<any, GetUserInfoResponse>(Api.getUserInfo);
};
